import sys
import pygame

from settings import Settings
from ship import Ship
import game_function as gf
from pygame.sprite import Group

def run_game():
    pygame.init()

    ai_settings = Settings()
    screen = pygame.display.set_mode((ai_settings.screen_width, ai_settings.screen_height))
    pygame.display.set_caption(ai_settings.caption)

    bullets = Group()

    ship = Ship(screen, ai_settings, bullets)


    while True:

        gf.check_event(ai_settings, screen, ship, bullets)
        screen.fill(ai_settings.bg_color)

        for b in bullets.sprites():
            if b.rect.y < 0:
                bullets.remove(b)
            else:
                b.draw()

        ship.blitme()
        bullets.update()


        pygame.display.flip()


run_game()